﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Kindohm.Life.Library
{
    public abstract class LifeForm : HeartbeatObject
    {
        bool isDead;
        CauseOfDeath causeOfDeath;

        public LifeForm()
        {
        }

        public CauseOfDeath CauseOfDeath
        {
            get { return this.causeOfDeath; }
        }

        public bool IsDead
        {
            get { return this.isDead; }
            set { this.isDead = value; }
        }

        public virtual void Die(CauseOfDeath cause)
        {
            this.causeOfDeath = cause;
            this.IsDead = true;
            this.Done = true;
            this.OnDie();
        }

        public event EventHandler<DiedEventArgs> Died;

        protected virtual void OnDie()
        {
            if (this.Died != null)
            {
                DiedEventArgs e = new DiedEventArgs(this);
                this.Died(this, e);
            }
        }

        public abstract void BeEaten();

    }
}
